package geo3D;

public class Point3D {
	private double x,y,z;

	public Point3D(double x, double y, double z) {
		super();
		this.x = x;
		this.y = y;
		this.z = z;
	}
	public String toString(){
			return "<"+x+","+z+","+y+">"; 
	}
	public String povray(double radius,int color){
		return "sphere{"+this.toString()+","+radius
		+"texture{pigment{color rgb <"+(color%256)+","+(color%256)+","+(color%256)+">}}}"; 
	}
	
	public double distance(Point3D e){
		double sum=(x-e.x)*(x-e.x); 
		sum+=(y-e.y)*(y-e.y); 
		sum+=(z-e.z)*(z-e.z);
		return Math.sqrt(sum); 
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		long temp;
		temp = Double.doubleToLongBits(x);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		temp = Double.doubleToLongBits(y);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		temp = Double.doubleToLongBits(z);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		return result;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Point3D other = (Point3D) obj;
		if (Double.doubleToLongBits(x) != Double.doubleToLongBits(other.x))
			return false;
		if (Double.doubleToLongBits(y) != Double.doubleToLongBits(other.y))
			return false;
		if (Double.doubleToLongBits(z) != Double.doubleToLongBits(other.z))
			return false;
		return true;
	} 
	

}
